/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * $Id: EnvironmentMeasurementTypes.hpp,v 1.3 2009-05-13 07:18:16 amaula Exp $
 *
 * \file
 * \brief Example types for a EnvironmentMeasurement interface. 
 * \author Matthieu Myrsky <matthieu.myrsky@tkk.fi>
 *
 */
#ifndef _MACI_ENVIRONMENTMEASUREMENTTYPES_HPP_
#define _MACI_ENVIRONMENTMEASUREMENTTYPES_HPP_
#include <inttypes.h>
#include "ownutils.h"
#include "owndebug.h"

namespace MaCI {

  /** MaCI - EnvironmentMeasurement interface.
   *
   * This namespace contains all the methods and types related
   * to the EnvironmentMeasurement interface.
   */
  namespace EnvironmentMeasurement {
    
    /** Enumeration types for EnvironmentMeasurement data elements.
     */
    enum EEnvironmentMeasurementType { 
      KTypeUnknown                   = -1, ///< Unkown type.
      KTypeTimestamp                 = 1,  ///< Common::TTimestamp element.
      KTypeCommand                   = 2,  ///< TCommand element.
      KTypeEnvironmentMeasurement    = 3,  ///< EnvironmentMeasurementEvent element.
      KTypeEnvironmentMeasurementheader = 4, ///< Contains TEnvironmentMeasurementHeader element.
      KTypePose2D                    = 5,  ///< TPose2D element.
      KTypeVariance2D                = 6,  ///< TVariance2D element.
      KTypeProbability               = 7   ///< TProbability element.
    };
    
    
    /** Enumerations for EnvironmentMeasurement Command.
     */
    enum EEnvironmentMeasurementCommand { 
      KCommandUnknown                         = 0, ///< Unkown command
      KCommandGetPositionWithEnvironment      = 1, ///< Get position with environment data
      KReplyPositionWithEnvironment           = 10 ///< Reply to get position with environment
    };


    /** EnvironmentMeasurement command.
     *
     * This structure contains command field to be used when sending
     * action requests to EnvironmentMeasurement enabled clients.
     *
     * \see EEnvironmentMeasurementCommand
     */
    struct TCommand 
    {
      TCommand(const unsigned int aCmd = 0,
               const unsigned int aData = 0) 
	: cmd(aCmd){}
      uint32_t cmd;             ///< Command
    };


    struct TEnvironmentMeasurementHeader{
      TEnvironmentMeasurementHeader(unsigned int aSizeOfData)
        :sizeOfData(aSizeOfData){}

      unsigned int sizeOfData;
    };

    /** 2D Pose.
     *
     * Defines a structure for representing a 2D Pose. 2D-Pose
     * includes the (\p x,\p y) position and \p heading. All units are SI, so
     * coordinates are specified as meters, and heading as
     * radians. Coordinate system is defined as follows:
     * - angles are positive CCW
     * - zero angle is towards the X axis
     * - positive movement moves by the posivite X axis
     * - 'turning left' means turning towards positive Y axis
     *
     * \note The single letter member \p a stands for 'Angle'
     */
    struct TPose2D
    {
      TPose2D(const float aX = 0.0, 
              const float aY = 0.0, 
              const float aHeading = 0.0)
        : x(aX),
          y(aY),
          a(aHeading) {}
      float x;       ///< X-axis in meters
      float y;       ///< Y-axis in meters
      float a;       ///< Heading in radians (positive CCW, Zero towards X-axis) 
    };
    
    /** 2D Variance.
     * 
     * Defines the type for representing variance of a 2D Pose.
     * Includes variance for \p x, \p y and \p heading fields.
     * Variance values are expressed in meters and radians.
     */
    typedef TPose2D TVariance2D;

    /** Position Probability.
     *
     * Defines the structure for representing a probability value.
     * The probability can be used to indicate the probability that
     * the given positition is what expected.
     *
     * \deprecated This structure is not exactly what is needed.
     * It must be thought over before taking into use. (Jari?)
     */
    struct TProbability
    {
      TProbability(const float aProb = 1.00)
        : probability(aProb) {}
      
      float probability; ///< Probability value ranging 0.00 - 1.00 (means 0% - 100%)
    };
  }
}

#endif
